home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 13 / AMIGAplus Sonderheft 13 (1998)(ICP)(DE)[!].iso / rexx / huntfile.bed < prev    next >
Text File  |  1997-12-03  |  1KB  |  67 lines

  1. /*
  2. ** $VER: HuntFile.bed 1.1 (21.04.96)
  3. **
  4. ** Hunt the current file under the cursor. Not perfect by far, but it works
  5. ** for simple includes and other simple files in the current dir :)
  6. **
  7. ** Written by Gerbert Nuijen
  8. */
  9.  
  10. OPTIONS RESULTS
  11.  
  12. GetChar
  13. IF RESULT="" | RESULT="RESULT" | RESULT= " " THEN DO
  14.    SetStatusBar "Cursor not on a (correct) word!"
  15.    Exit
  16. END
  17.  
  18. break=FALSE
  19.  
  20. DO WHILE break=FALSE
  21.    Getchar
  22.    char = RESULT
  23.    IF char="<" THEN DO
  24.       break=TRUE
  25.       endchar=">"
  26.       MoveRight
  27.    END
  28.    IF char=" " | char="RESULT" THEN DO /* If it is an Return code, RESULT
  29.                                           is given as a RESULT of GetChar */
  30.       break=TRUE
  31.       endchar=" "
  32.       MoveRight
  33.    END
  34.    MoveLeft
  35. END
  36.  
  37. exe=""
  38.  
  39. DO WHILE char ~= endchar
  40.    MoveRight
  41.    GetChar
  42.    char = RESULT
  43.    IF char="RESULT" | char=endchar THEN DO   /* that's for return codes */
  44.       char=endchar
  45.    END
  46.    ELSE DO
  47.       exe = exe || char
  48.    END
  49. END
  50.  
  51. ExistsFile exe
  52.  
  53. IF RESULT = "YES" THEN DO
  54.    OpenDoc exe
  55.    EXIT
  56. END
  57. ELSE DO
  58.    exe = "Include:" || exe
  59.    ExistsFile exe
  60.    IF RESULT = "YES" THEN DO
  61.       OpenDoc exe
  62.    END
  63.    ELSE DO
  64.       SetStatusBar "Can't find file! : " || exe
  65.    END
  66. END
  67.